package org.yxt.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@Slf4j
@RestController
@RequestMapping(value = "consumer")
public class ConsulConsumerOrderController {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 访问注册到consul中的支付订单模块
     *
     * @return
     */
    @GetMapping(value = "consulOrder")
    public String consulOrder() {
        String consulPaymentOrderServiceId = "http://consul-provider-payment";
        String forObject = restTemplate.getForObject(consulPaymentOrderServiceId.concat("/payment/consul"), String.class);
        return forObject;
    }
}
